//
//  ShareViewController.m
//  WeChatE
//
//  Created by feng on 2016/10/10.
//  Copyright © 2016年 小码哥. All rights reserved.
//

#import "ShareViewController.h"
#import "AppDelegate.h"
#import "MyTodayTestViewControlller.h"
#import <objc/runtime.h>
@interface ShareViewController ()

@end

@implementation ShareViewController
-(void)viewDidLoad
{
    [super viewDidLoad];
//    for (UIView*indexV in self.view.subviews) {
//        [indexV removeFromSuperview];
//    }
//     self.textView.superclass;
    
    NSLog(@">>>>>>>>>%@",[self.textView.superview class]);
    self.title=@"梅斯医学";
    UIScrollView* indeScrollView=self.textView.superview;
    UIButton* twoButton=[[UIButton alloc] initWithFrame:CGRectMake(80, 10, 50, 30)];
    twoButton.titleLabel.font=[UIFont systemFontOfSize:10];
    [twoButton setTitle:@"B Action" forState:UIControlStateNormal];
    [indeScrollView addSubview:twoButton];

}
//- (UIView *)loadPreviewView
//{
//    UIView* costomView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 400)];
//    costomView.backgroundColor=[UIColor yellowColor];
//    return costomView;
//}
- (BOOL)isContentValid {
    // Do validation of contentText and/or NSExtensionContext attachments here
    if (self.textView.text.length>100) {
        return NO;
    }
    return YES;
}
-(void)presentationAnimationDidFinish
{

}
- (void)didSelectPost {
    // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
//    NSLog(@"self.textView.text:%@",self.textView.text);
//    NSLog(@"self.contentText:%@",self.contentText);
    
    NSExtensionItem*indexItem=[self.extensionContext.inputItems lastObject];
    NSItemProvider *providerIndex=[indexItem.attachments lastObject];
    NSLog(@"providerIndex is:%@  indexItem.attachments:%lu",providerIndex,indexItem.attachments.count);
    [providerIndex loadItemForTypeIdentifier:@"public.url" options:nil completionHandler:^(id<NSSecureCoding>  _Nullable item, NSError * _Null_unspecified error) {
        
        
        
    }];
    
//    NSExtensionItem
    // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
    [self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];
}

- (NSArray *)configurationItems {
    // To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
    NSMutableArray* itemArray=[NSMutableArray array];
    for (int M=0; M<1; M++) {
        
        SLComposeSheetConfigurationItem*everyItem=[[SLComposeSheetConfigurationItem alloc] init];
        everyItem.title=[NSString stringWithFormat:@"index of: %d",M];
        everyItem.value=@"123";
        everyItem.tapHandler=^()
        {
//            FBDPictureViewController* selectVC=[[FBDPictureViewController alloc] init];
            MyTodayTestViewControlller*selectVC=[[MyTodayTestViewControlller alloc] init];
            [self pushConfigurationViewController:selectVC];
//
            
        };
        [itemArray addObject:everyItem];
        
    }
    
    
    return itemArray;
}

@end
